﻿using Miao;
using RimWorld;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
namespace Miao
{
    public class StorytellerComp_BanCategoryMTB : StorytellerComp
    {
        protected StorytellerCompProperties_BanCategoryMTB Props => (StorytellerCompProperties_BanCategoryMTB)props;

        public override IEnumerable<FiringIncident> MakeIntervalIncidents(IIncidentTarget target)
        {
            float num = Props.mtbDays;
            if (Props.mtbDaysFactorByDaysPassedCurve != null)
            {
                num *= Props.mtbDaysFactorByDaysPassedCurve.Evaluate(GenDate.DaysPassedSinceSettleFloat);
            }
            if (Rand.MTBEventOccurs(num, 60000f, 1000f))
            {
                IncidentParms parms = GenerateParms(Props.category, target);

                var categorys = UsableIncidentsInCategory(Props.category, parms);

                categorys = categorys.Where((a) =>//跳过不需要的Incident
                {
                    return !Props.banIncident.Contains(a);
                });

                if (TrySelectRandomIncident(categorys, out var foundDef, target))
                {
                    yield return new FiringIncident(foundDef, this, parms);
                }
            }
        }

        public override string ToString()
        {
            return $"{base.ToString()} {Props.category}";
        }
    }
}
